package com.cakin.javademo;

/**
 * @ClassName: WhileDemo
 * @Description: 测试while循环
 * @Date: 2020/6/14
 * @Author: cakin
 */
public class WhileDemo {
    public static void main(String[] args) {
        // while
        // 循环打印一段话10次
        int i = 0;
        while (i < 10) {
            if (i == 5) {
                // break跳出整个循环
                // break;
                // continue跳出本次循环
                i++;
                continue;
            }
            System.out.println("打印10次");
            // 循环条件一定要增加或者减少
            i++;
        }
        System.out.println("=============================1");

        // do wile
        int j = 0;
        do {
            System.out.println("打印10次");
            j++;
        } while (j < 10);
        System.out.println("=============================");

        // for 循环打印10次
        for (int k = 0; k < 10; k++) {
            System.out.println("打印10次");
        }

        int[] a = {1,2,3,4,5};
        for (int m: a) {
            System.out.println(m);
        }
        System.out.println("=============================");
        String[] names ={"cakin1","cakin2","cakin3"};
        for (String name:names
             ) {
            System.out.println(name);
        }
    }
}
